#pragma once

#include "comm/znx_log.h"


typedef struct {
    znx_log_t               *log;
    znx_str_t               context;
} znx_http_log_t;


#define ZNX_HTTP_LOG_INFO(hlog, fmt, args...)                   \
    if (LOG_LEVEL_INFO >= (hlog.log)->level)                    \
        znx_log_fmt_output(hlog.log, "info", __FILE__, __LINE__, &hlog.context, 0, fmt, ##args)


#define ZNX_HTTP_LOG_DEBUG(hlog, fmt, args...)                  \
    if (LOG_LEVEL_DEBUG >= (hlog.log)->level)                   \
        znx_log_fmt_output(hlog.log, "debug", __FILE__, __LINE__, &hlog.context, 0, fmt, ##args)


#define ZNX_HTTP_LOG_WARN(hlog, fmt, args...)                   \
    if (LOG_LEVEL_WARN >= (hlog.log)->level)                    \
        znx_log_fmt_output(hlog.log, "warn", __FILE__, __LINE__, &hlog.context, 0, fmt, ##args)


#define ZNX_HTTP_LOG_ERROR(hlog, fmt, args...)                  \
    if (LOG_LEVEL_ERROR >= (hlog.log)->level)                   \
        znx_log_fmt_output(hlog.log, "error", __FILE__, __LINE__, &hlog.context, 0, fmt, ##args)


#define ZNX_HTTP_LOG_FATAL(hlog, fmt, args...)                  \
        znx_log_fmt_output(hlog.log, "fatal", __FILE__, __LINE__, &hlog.context, 1, fmt, ##args)
